package com.shenzhenai.composebasic.components

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CutCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.shenzhenai.composebasic.R

/**
 * @author huangzehui
 * @date 14/9/2025 下午10:59 周日
 * @description
 *
 * Surface 用法
 * https://www.bilibili.com/video/BV1CT4y1Q7de?vd_source=e07cc8cc94eb22bd76722071b03cd199&spm_id_from=333.788.player.switch
 */


@Composable
fun SurfaceSample() {
    Surface(
        /**
         * 设置形状
         *
         * CircleShape：胶囊形状(椭圆形)
         * RoundedCornerShape : 圆角
         * CutCornerShape : 矩形的每个角，都切去一个三角形
         *
         */
//        shape = CircleShape
//        shape = RoundedCornerShape(20.dp)
        shape = CutCornerShape(50.dp),
        color = Color.Blue,
        // 边框
        border = BorderStroke(1.dp, Color.Green),
        // 设置阴影
        shadowElevation = 10.dp
    ) {
        Image(
            painter = painterResource(id = R.drawable.qier),
            contentDescription = null
        )
    }
}

@Preview
@Composable
fun SurfaceSamplePreview() {
    SurfaceSample()
}